#include "StdAfx.h"
#include "UIMemClientDC.h"

CUIMemClientDC::CUIMemClientDC( HWND hWnd ): CUIClientDC( hWnd ), m_bmpOrignMem( NULL ), m_bmpOldOrignMem( NULL )
    , m_dcMem( NULL ), m_hWnd( hWnd )
{
    ::GetClipBox( CUIClientDC::GetDC(), &m_rect );
    m_dcMem =::CreateCompatibleDC( CUIClientDC::GetDC() );
    m_bmpOrignMem =::CreateCompatibleBitmap( CUIClientDC::GetDC(), m_rect.right - m_rect.left, m_rect.bottom - m_rect.top );
    m_bmpOldOrignMem = ( HBITMAP )::SelectObject( m_dcMem, m_bmpOrignMem );
}


CUIMemClientDC::~CUIMemClientDC( void )
{
    ::BitBlt( CUIClientDC::GetDC(), 0, 0, m_rect.right - m_rect.left, m_rect.bottom - m_rect.top, m_dcMem, 0, 0, SRCCOPY );
    ::SelectObject( m_dcMem, m_bmpOldOrignMem );
    ::DeleteObject( m_bmpOldOrignMem );
    ::DeleteObject( m_bmpOrignMem );
    ::DeleteObject( m_dcMem );
}

HDC CUIMemClientDC::GetDC()
{
    return m_dcMem;
}

